﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

public partial class product_saving_user_saving_details : System.Web.UI.Page
{
    SavingDetailsBLL bll = new SavingDetailsBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        //DataSet self = bll.getSelfDetail();

        if (!IsPostBack)
        {

            String id = (Request.QueryString["custID"]);
            bll.custID = id;
            this.hfCustId.Value = id;

            DataSet self = bll.getSelfDetail();
            this.fvDetails.DataSource = bll.getSelfDetail();
            this.fvDetails.DataBind();


        }


    }

    protected void btnTerminate_Click(object sender, EventArgs e)
    {
        string strConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection myConnection = new SqlConnection(strConnectionString);

        try
        {
            myConnection = DBManager.getSqlConnection();
            SqlCommand myCommandc = new SqlCommand("DELETE FROM SAVING_ACCOUNT WHERE custID =" + hfCustId.Value, myConnection);
            myConnection.Open();
            myCommandc.Parameters.AddWithValue("@custId", hfCustId.Value);
            myCommandc.ExecuteNonQuery();

            Label1.Text = "Your account has been terminated. Please refresh the page. Thank you.";

            myConnection.Close();
        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            Response.Write(ex);
        }
        finally
        {
            myConnection.Close();
        }
    }

    protected void btnEdit_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/product/saving/admin/saving_edit.aspx?custID=" + this.hfCustId.Value);
    }
}